package com.wanshi.entity;

import java.util.ArrayList;
import java.util.List;

public class PageInfo {

    //1 列表  List
    private List<User> list = new ArrayList<>();

    //2 总共多少条数据
    private long total;

    //3 每页显示多少条
    private int size;

    //4 当前页   10
    private int page;

    //5 上一页  下一页  尾页

    public int getPrve(){
        return page == 1 ? 1 : page-1;
    }
    public int getStart(){
        if (getLast()<=11){
            return 1;
        }else {
            if (page<=5){
                return 1;
            }else if (page >=getLast()-4){
                return getLast()-10;
            }else {
                return page-5;
            }
        }
    }
    public int getEnd(){
        if (getLast()<=11){
            return getLast();
        }else {
            if (page<=5){
                return 11;
            }else if (page >=getLast()-4){
                return getLast();
            }else {
                return page+5;
            }
        }
    }

    //80   10  --> 8     98  10 ---> 10
    public int getLast(){
        return  (int) (total%size == 0?total/size : total/size+1);
    }

    public int getNext(){
        return page == getLast() ? page :  page+1 ;
    }


    public List<User> getList() {
        return list;
    }

    public void setList(List<User> list) {
        this.list = list;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }
}
